package com.wuhao.shootclient.room.dao;


import androidx.lifecycle.LiveData;
import androidx.room.Dao;
import androidx.room.Insert;
import androidx.room.Query;

import com.wuhao.shootclient.room.bean.ReceiveMsgBean;

import java.util.List;

@Dao
public interface ReceiveBeanDao {
    @Insert
    void insertOne(ReceiveMsgBean bean);

    @Query("SELECT * FROM ReceiveMsgBean ")
    LiveData<List<ReceiveMsgBean>> queryAll();

    @Query("DELETE FROM ReceiveMsgBean")
    void deleteAll();

    /**
     * 查询最后一条数据
     * @return 返回最后一条数据
     */
    @Query("SELECT * FROM receivemsgbean order by id DESC limit 1")
    LiveData<ReceiveMsgBean> getLastOne();

    /**
     * 按照接收时间排序返回所有数据
     * @return
     */
    @Query("SELECT * FROM receivemsgbean order by receiveTime ASC")
    LiveData<List<ReceiveMsgBean>> getAllDataOrderByTime();
}
